//
//  StatusCellBottomView.swift
//  新浪微博01
//
//  Created by 李国伟 on 15/12/12.
//  Copyright © 2015年 李国伟. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
     //懒加载控件
    private lazy var retweetButton: UIButton = UIButton(imageName: "timeline_icon_retweet", title: " 转发", fontsize: 14, color: UIColor.darkGrayColor())

    private lazy var commendButton: UIButton = UIButton(imageName: "timeline_icon_comment", title: " 评论", fontsize: 14, color: UIColor.darkGrayColor())

    private lazy var likeButton: UIButton = UIButton(imageName: "timeline_icon_unlike", title: " 赞", fontsize: 14, color: UIColor.darkGrayColor())

}

/// 添加控件并设置约束
extension StatusCellBottomView{
    
    private func setupUI(){
        addSubview(retweetButton)
        addSubview(commendButton)
        addSubview(likeButton)
        let lineleft = lineView()
        let lineright = lineView()
        addSubview(lineleft)
        addSubview(lineright)
        
        //转发
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
        }
        
        //评论
        commendButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.height.equalTo(retweetButton)
            make.width.equalTo(retweetButton)
            make.top.equalTo(retweetButton)
        }
        
        //点赞
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commendButton.snp_right)
            make.top.equalTo(commendButton)
            make.height.equalTo(commendButton)
            make.width.equalTo(commendButton)
            make.right.equalTo(self)
        }
        
        //分割线
        let linewith = 0.5
        let scale = 0.4
        lineleft.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.width.equalTo(linewith)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(scale)
            make.centerY.equalTo(retweetButton)
        }
        
        lineright.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commendButton.snp_right)
            make.width.equalTo(linewith)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(scale)
            make.centerY.equalTo(retweetButton)
//            make.left.equalTo(commendButton.snp_right)
//            make.centerY.equalTo(retweetButton.snp_centerY)
//            make.width.equalTo(linewith)
//            make.height.equalTo(retweetButton.snp_height).multipliedBy(scale)
            
        }
    }
    
    //分割线专用
    private func lineView () -> UIView{
        
        let v = UIView()
        v.backgroundColor = UIColor(white: 0.7, alpha: 1)
        return v
    }
}